home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 6 / CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso / cucd / prog / gnu-c / src / gcc-2.7.0-amiga / bi-parser.c < prev    next >
C/C++ Source or Header  |  1995-06-15  |  25KB  |  969 lines

  1.  
  2. /*  A Bison parser, made from bi-parser.y with Bison version GNU Bison version 1.22
  3.   */
  4.  
  5. #define YYBISON 1  /* Identify Bison output.  */
  6.  
  7. #define    DEFOP    258
  8. #define    STRING    259
  9.  
  10. #line 22 "bi-parser.y"
  11.  
  12.  
  13. #include <stdio.h>
  14. #include "hconfig.h"
  15. #include "bi-defs.h"
  16.  
  17. extern char yytext[];
  18. extern int yyleng;
  19.  
  20.  
  21. /* Chain of all defs built by the parser. */
  22. struct def *defs;
  23. int ndefs;
  24.  
  25. static struct node *makenode ();
  26. static struct variation *makevar ();
  27. static struct def *makedef ();
  28.  
  29. void yyerror ();
  30.  
  31.  
  32. #line 44 "bi-parser.y"
  33. typedef union
  34. {
  35.   char *string;
  36.   struct def *def;
  37.   struct variation *variation;
  38.   struct node *node;
  39. } YYSTYPE;
  40.  
  41. #ifndef YYLTYPE
  42. typedef
  43.   struct yyltype
  44.     {
  45.       int timestamp;
  46.       int first_line;
  47.       int first_column;
  48.       int last_line;
  49.       int last_column;
  50.       char *text;
  51.    }
  52.   yyltype;
  53.  
  54. #define YYLTYPE yyltype
  55. #endif
  56.  
  57. #include <stdio.h>
  58.  
  59. #ifndef __cplusplus
  60. #ifndef __STDC__
  61. #define const
  62. #endif
  63. #endif
  64.  
  65.  
  66.  
  67. #define    YYFINAL        39
  68. #define    YYFLAG        -32768
  69. #define    YYNTBASE    8
  70.  
  71. #define YYTRANSLATE(x) ((unsigned)(x) <= 259 ? yytranslate[x] : 17)
  72.  
  73. static const char yytranslate[] = {     0,
  74.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  75.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  76.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  77.      2,     2,     2,     2,     2,     2,     2,     2,     2,     5,
  78.      7,     2,     2,     6,     2,     2,     2,     2,     2,     2,
  79.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  80.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  81.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  82.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  83.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  84.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  85.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  86.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  87.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  88.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  89.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  90.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  91.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  92.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  93.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  94.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  95.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  96.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  97.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  98.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  99.      2,     2,     2,     2,     2,     1,     2,     3,     4
  100. };
  101.  
  102. #if YYDEBUG != 0
  103. static const short yyprhs[] = {     0,
  104.      0,     2,     4,     7,    18,    20,    24,    28,    34,    42,
  105.     52,    53,    55,    59,    60,    62,    66
  106. };
  107.  
  108. static const short yyrhs[] = {     9,
  109.      0,    10,     0,     9,    10,     0,     3,     5,     4,     6,
  110.     13,     6,     5,    11,     7,     7,     0,    12,     0,    11,
  111.      6,    12,     0,     5,    13,     7,     0,     5,    13,     6,
  112.     14,     7,     0,     5,    13,     6,    14,     6,    14,     7,
  113.      0,     5,    13,     6,    14,     6,    14,     6,    14,     7,
  114.      0,     0,     4,     0,     5,    15,     7,     0,     0,    16,
  115.      0,    16,     6,    15,     0,     4,     0
  116. };
  117.  
  118. #endif
  119.  
  120. #if YYDEBUG != 0
  121. static const short yyrline[] = { 0,
  122.     60,    65,    67,    71,    76,    78,    82,    85,    87,    89,
  123.     93,    95,    98,   101,   105,   108,   112
  124. };
  125.  
  126. static const char * const yytname[] = {   "$","error","$illegal.","DEFOP","STRING",
  127. "'('","','","')'","top","defs","def","variations","variation","opt_string","list",
  128. "items","item",""
  129. };
  130. #endif
  131.  
  132. static const short yyr1[] = {     0,
  133.      8,     9,     9,    10,    11,    11,    12,    12,    12,    12,
  134.     13,    13,    14,    14,    15,    15,    16
  135. };
  136.  
  137. static const short yyr2[] = {     0,
  138.      1,     1,     2,    10,     1,     3,     3,     5,     7,     9,
  139.      0,     1,     3,     0,     1,     3,     1
  140. };
  141.  
  142. static const short yydefact[] = {     0,
  143.      0,     1,     2,     0,     3,     0,    11,    12,     0,     0,
  144.      0,    11,     0,     5,     0,     0,     0,    14,     7,     6,
  145.      4,     0,     0,    17,     0,    15,    14,     8,    13,     0,
  146.      0,    16,    14,     9,     0,    10,     0,     0,     0
  147. };
  148.  
  149. static const short yydefgoto[] = {    37,
  150.      2,     3,    13,    14,     9,    23,    25,    26
  151. };
  152.  
  153. static const short yypact[] = {     2,
  154.      6,     2,-32768,     8,-32768,     7,    10,-32768,     9,    11,
  155.     12,    10,    -5,-32768,    -3,    12,    13,    14,-32768,-32768,
  156. -32768,    17,     1,-32768,    15,    18,    14,-32768,-32768,    17,
  157.      3,-32768,    14,-32768,    16,-32768,    25,    26,-32768
  158. };
  159.  
  160. static const short yypgoto[] = {-32768,
  161. -32768,    27,-32768,    19,    20,   -27,   -12,-32768
  162. };
  163.  
  164.  
  165. #define    YYLAST        35
  166.  
  167.  
  168. static const short yytable[] = {    31,
  169.     16,    17,    18,    19,     1,    35,    27,    28,    33,    34,
  170.      4,     6,     7,     8,    10,    11,    12,    32,    22,    21,
  171.     24,    29,    36,    30,    38,    39,     0,     0,     5,     0,
  172.      0,    15,     0,     0,    20
  173. };
  174.  
  175. static const short yycheck[] = {    27,
  176.      6,     7,     6,     7,     3,    33,     6,     7,     6,     7,
  177.      5,     4,     6,     4,     6,     5,     5,    30,     5,     7,
  178.      4,     7,     7,     6,     0,     0,    -1,    -1,     2,    -1,
  179.     -1,    12,    -1,    -1,    16
  180. };
  181. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  182. #line 3 "/usr/local/lib/bison.simple"
  183.  
  184. /* Skeleton output parser for bison,
  185.    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  186.  
  187.    This program is free software; you can redistribute it and/or modify
  188.    it under the terms of the GNU General Public License as published by
  189.    the Free Software Foundation; either version 1, or (at your option)
  190.    any later version.
  191.  
  192.    This program is distributed in the hope that it will be useful,
  193.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  194.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  195.    GNU General Public License for more details.
  196.  
  197.    You should have received a copy of the GNU General Public License
  198.    along with this program; if not, write to the Free Software
  199.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  200.  
  201.  
  202. #ifndef alloca
  203. #ifdef __GNUC__
  204. #define alloca __builtin_alloca
  205. #else /* not GNU C.  */
  206. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
  207. #include <alloca.h>
  208. #else /* not sparc */
  209. #if defined (MSDOS) && !defined (__TURBOC__)
  210. #include <malloc.h>
  211. #else /* not MSDOS, or __TURBOC__ */
  212. #if defined(_AIX)
  213. #include <malloc.h>
  214.  #pragma alloca
  215. #else /* not MSDOS, __TURBOC__, or _AIX */
  216. #ifdef __hpux
  217. #ifdef __cplusplus
  218. extern "C" {
  219. void *alloca (unsigned int);
  220. };
  221. #else /* not __cplusplus */
  222. void *alloca ();
  223. #endif /* not __cplusplus */
  224. #endif /* __hpux */
  225. #endif /* not _AIX */
  226. #endif /* not MSDOS, or __TURBOC__ */
  227. #endif /* not sparc.  */
  228. #endif /* not GNU C.  */
  229. #endif /* alloca not defined.  */
  230.  
  231. /* This is the parser code that is written into each bison parser
  232.   when the %semantic_parser declaration is not specified in the grammar.
  233.   It was written by Richard Stallman by simplifying the hairy parser
  234.   used when %semantic_parser is specified.  */
  235.  
  236. /* Note: there must be only one dollar sign in this file.
  237.    It is replaced by the list of actions, each action
  238.    as one case of the switch.  */
  239.  
  240. #define yyerrok        (yyerrstatus = 0)
  241. #define yyclearin    (yychar = YYEMPTY)
  242. #define YYEMPTY        -2
  243. #define YYEOF        0
  244. #define YYACCEPT    return(0)
  245. #define YYABORT     return(1)
  246. #define YYERROR        goto yyerrlab1
  247. /* Like YYERROR except do call yyerror.
  248.    This remains here temporarily to ease the
  249.    transition to the new meaning of YYERROR, for GCC.
  250.    Once GCC version 2 has supplanted version 1, this can go.  */
  251. #define YYFAIL        goto yyerrlab
  252. #define YYRECOVERING()  (!!yyerrstatus)
  253. #define YYBACKUP(token, value) \
  254. do                                \
  255.   if (yychar == YYEMPTY && yylen == 1)                \
  256.     { yychar = (token), yylval = (value);            \
  257.       yychar1 = YYTRANSLATE (yychar);                \
  258.       YYPOPSTACK;                        \
  259.       goto yybackup;                        \
  260.     }                                \
  261.   else                                \
  262.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  263. while (0)
  264.  
  265. #define YYTERROR    1
  266. #define YYERRCODE    256
  267.  
  268. #ifndef YYPURE
  269. #define YYLEX        yylex()
  270. #endif
  271.  
  272. #ifdef YYPURE
  273. #ifdef YYLSP_NEEDED
  274. #define YYLEX        yylex(&yylval, &yylloc)
  275. #else
  276. #define YYLEX        yylex(&yylval)
  277. #endif
  278. #endif
  279.  
  280. /* If nonreentrant, generate the variables here */
  281.  
  282. #ifndef YYPURE
  283.  
  284. int    yychar;            /*  the lookahead symbol        */
  285. YYSTYPE    yylval;            /*  the semantic value of the        */
  286.                 /*  lookahead symbol            */
  287.  
  288. #ifdef YYLSP_NEEDED
  289. YYLTYPE yylloc;            /*  location data for the lookahead    */
  290.                 /*  symbol                */
  291. #endif
  292.  
  293. int yynerrs;            /*  number of parse errors so far       */
  294. #endif  /* not YYPURE */
  295.  
  296. #if YYDEBUG != 0
  297. int yydebug;            /*  nonzero means print parse trace    */
  298. /* Since this is uninitialized, it does not stop multiple parsers
  299.    from coexisting.  */
  300. #endif
  301.  
  302. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  303.  
  304. #ifndef    YYINITDEPTH
  305. #define YYINITDEPTH 200
  306. #endif
  307.  
  308. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  309.     (effective only if the built-in stack extension method is used).  */
  310.  
  311. #if YYMAXDEPTH == 0
  312. #undef YYMAXDEPTH
  313. #endif
  314.  
  315. #ifndef YYMAXDEPTH
  316. #define YYMAXDEPTH 10000
  317. #endif
  318.  
  319. /* Prevent warning if -Wstrict-prototypes.  */
  320. #ifdef __GNUC__
  321. int yyparse (void);
  322. #endif
  323.  
  324. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  325. #define __yy_bcopy(FROM,TO,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  326. #else                /* not GNU C or C++ */
  327. #ifndef __cplusplus
  328.  
  329. /* This is the most reliable way to avoid incompatibilities
  330.    in available built-in functions on various systems.  */
  331. static void
  332. __yy_bcopy (from, to, count)
  333.      char *from;
  334.      char *to;
  335.      int count;
  336. {
  337.   register char *f = from;
  338.   register char *t = to;
  339.   register int i = count;
  340.  
  341.   while (i-- > 0)
  342.     *t++ = *f++;
  343. }
  344.  
  345. #else /* __cplusplus */
  346.  
  347. /* This is the most reliable way to avoid incompatibilities
  348.    in available built-in functions on various systems.  */
  349. static void
  350. __yy_bcopy (char *from, char *to, int count)
  351. {
  352.   register char *f = from;
  353.   register char *t = to;
  354.   register int i = count;
  355.  
  356.   while (i-- > 0)
  357.     *t++ = *f++;
  358. }
  359.  
  360. #endif
  361. #endif
  362.  
  363. #line 184 "/usr/local/lib/bison.simple"
  364.  
  365. /* The user can define YYPARSE_PARAM as the name of an argument to be passed
  366.    into yyparse.  The argument should have type void *.
  367.    It should actually point to an object.
  368.    Grammar actions can access the variable by casting it
  369.    to the proper pointer type.  */
  370.  
  371. #ifdef YYPARSE_PARAM
  372. #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
  373. #else
  374. #define YYPARSE_PARAM
  375. #define YYPARSE_PARAM_DECL
  376. #endif
  377.  
  378. int
  379. yyparse(YYPARSE_PARAM)
  380.      YYPARSE_PARAM_DECL
  381. {
  382.   register int yystate;
  383.   register int yyn;
  384.   register short *yyssp;
  385.   register YYSTYPE *yyvsp;
  386.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  387.   int yychar1 = 0;        /*  lookahead token as an internal (translated) token number */
  388.  
  389.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  390.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  391.  
  392.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  393.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  394.  
  395. #ifdef YYLSP_NEEDED
  396.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  397.   YYLTYPE *yyls = yylsa;
  398.   YYLTYPE *yylsp;
  399.  
  400. #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
  401. #else
  402. #define YYPOPSTACK   (yyvsp--, yyssp--)
  403. #endif
  404.  
  405.   int yystacksize = YYINITDEPTH;
  406.  
  407. #ifdef YYPURE
  408.   int yychar;
  409.   YYSTYPE yylval;
  410.   int yynerrs;
  411. #ifdef YYLSP_NEEDED
  412.   YYLTYPE yylloc;
  413. #endif
  414. #endif
  415.  
  416.   YYSTYPE yyval;        /*  the variable used to return        */
  417.                 /*  semantic values from the action    */
  418.                 /*  routines                */
  419.  
  420.   int yylen;
  421.  
  422. #if YYDEBUG != 0
  423.   if (yydebug)
  424.     fprintf(stderr, "Starting parse\n");
  425. #endif
  426.  
  427.   yystate = 0;
  428.   yyerrstatus = 0;
  429.   yynerrs = 0;
  430.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  431.  
  432.   /* Initialize stack pointers.
  433.      Waste one element of value and location stack
  434.      so that they stay on the same level as the state stack.
  435.      The wasted elements are never initialized.  */
  436.  
  437.   yyssp = yyss - 1;
  438.   yyvsp = yyvs;
  439. #ifdef YYLSP_NEEDED
  440.   yylsp = yyls;
  441. #endif
  442.  
  443. /* Push a new state, which is found in  yystate  .  */
  444. /* In all cases, when you get here, the value and location stacks
  445.    have just been pushed. so pushing a state here evens the stacks.  */
  446. yynewstate:
  447.  
  448.   *++yyssp = yystate;
  449.  
  450.   if (yyssp >= yyss + yystacksize - 1)
  451.     {
  452.       /* Give user a chance to reallocate the stack */
  453.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  454.       YYSTYPE *yyvs1 = yyvs;
  455.       short *yyss1 = yyss;
  456. #ifdef YYLSP_NEEDED
  457.       YYLTYPE *yyls1 = yyls;
  458. #endif
  459.  
  460.       /* Get the current used size of the three stacks, in elements.  */
  461.       int size = yyssp - yyss + 1;
  462.  
  463. #ifdef yyoverflow
  464.       /* Each stack pointer address is followed by the size of
  465.      the data in use in that stack, in bytes.  */
  466. #ifdef YYLSP_NEEDED
  467.       /* This used to be a conditional around just the two extra args,
  468.      but that might be undefined if yyoverflow is a macro.  */
  469.       yyoverflow("parser stack overflow",
  470.          &yyss1, size * sizeof (*yyssp),
  471.          &yyvs1, size * sizeof (*yyvsp),
  472.          &yyls1, size * sizeof (*yylsp),
  473.          &yystacksize);
  474. #else
  475.       yyoverflow("parser stack overflow",
  476.          &yyss1, size * sizeof (*yyssp),
  477.          &yyvs1, size * sizeof (*yyvsp),
  478.          &yystacksize);
  479. #endif
  480.  
  481.       yyss = yyss1; yyvs = yyvs1;
  482. #ifdef YYLSP_NEEDED
  483.       yyls = yyls1;
  484. #endif
  485. #else /* no yyoverflow */
  486.       /* Extend the stack our own way.  */
  487.       if (yystacksize >= YYMAXDEPTH)
  488.     {
  489.       yyerror("parser stack overflow");
  490.       return 2;
  491.     }
  492.       yystacksize *= 2;
  493.       if (yystacksize > YYMAXDEPTH)
  494.     yystacksize = YYMAXDEPTH;
  495.       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  496.       __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  497.       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  498.       __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  499. #ifdef YYLSP_NEEDED
  500.       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  501.       __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  502. #endif
  503. #endif /* no yyoverflow */
  504.  
  505.       yyssp = yyss + size - 1;
  506.       yyvsp = yyvs + size - 1;
  507. #ifdef YYLSP_NEEDED
  508.       yylsp = yyls + size - 1;
  509. #endif
  510.  
  511. #if YYDEBUG != 0
  512.       if (yydebug)
  513.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  514. #endif
  515.  
  516.       if (yyssp >= yyss + yystacksize - 1)
  517.     YYABORT;
  518.     }
  519.  
  520. #if YYDEBUG != 0
  521.   if (yydebug)
  522.     fprintf(stderr, "Entering state %d\n", yystate);
  523. #endif
  524.  
  525.   goto yybackup;
  526.  yybackup:
  527.  
  528. /* Do appropriate processing given the current state.  */
  529. /* Read a lookahead token if we need one and don't already have one.  */
  530. /* yyresume: */
  531.  
  532.   /* First try to decide what to do without reference to lookahead token.  */
  533.  
  534.   yyn = yypact[yystate];
  535.   if (yyn == YYFLAG)
  536.     goto yydefault;
  537.  
  538.   /* Not known => get a lookahead token if don't already have one.  */
  539.  
  540.   /* yychar is either YYEMPTY or YYEOF
  541.      or a valid token in external form.  */
  542.  
  543.   if (yychar == YYEMPTY)
  544.     {
  545. #if YYDEBUG != 0
  546.       if (yydebug)
  547.     fprintf(stderr, "Reading a token: ");
  548. #endif
  549.       yychar = YYLEX;
  550.     }
  551.  
  552.   /* Convert token to internal form (in yychar1) for indexing tables with */
  553.  
  554.   if (yychar <= 0)        /* This means end of input. */
  555.     {
  556.       yychar1 = 0;
  557.       yychar = YYEOF;        /* Don't call YYLEX any more */
  558.  
  559. #if YYDEBUG != 0
  560.       if (yydebug)
  561.     fprintf(stderr, "Now at end of input.\n");
  562. #endif
  563.     }
  564.   else
  565.     {
  566.       yychar1 = YYTRANSLATE(yychar);
  567.  
  568. #if YYDEBUG != 0
  569.       if (yydebug)
  570.     {
  571.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  572.       /* Give the individual parser a way to print the precise meaning
  573.          of a token, for further debugging info.  */
  574. #ifdef YYPRINT
  575.       YYPRINT (stderr, yychar, yylval);
  576. #endif
  577.       fprintf (stderr, ")\n");
  578.     }
  579. #endif
  580.     }
  581.  
  582.   yyn += yychar1;
  583.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  584.     goto yydefault;
  585.  
  586.   yyn = yytable[yyn];
  587.  
  588.   /* yyn is what to do for this token type in this state.
  589.      Negative => reduce, -yyn is rule number.
  590.      Positive => shift, yyn is new state.
  591.        New state is final state => don't bother to shift,
  592.        just return success.
  593.      0, or most negative number => error.  */
  594.  
  595.   if (yyn < 0)
  596.     {
  597.       if (yyn == YYFLAG)
  598.     goto yyerrlab;
  599.       yyn = -yyn;
  600.       goto yyreduce;
  601.     }
  602.   else if (yyn == 0)
  603.     goto yyerrlab;
  604.  
  605.   if (yyn == YYFINAL)
  606.     YYACCEPT;
  607.  
  608.   /* Shift the lookahead token.  */
  609.  
  610. #if YYDEBUG != 0
  611.   if (yydebug)
  612.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  613. #endif
  614.  
  615.   /* Discard the token being shifted unless it is eof.  */
  616.   if (yychar != YYEOF)
  617.     yychar = YYEMPTY;
  618.  
  619.   *++yyvsp = yylval;
  620. #ifdef YYLSP_NEEDED
  621.   *++yylsp = yylloc;
  622. #endif
  623.  
  624.   /* count tokens shifted since error; after three, turn off error status.  */
  625.   if (yyerrstatus) yyerrstatus--;
  626.  
  627.   yystate = yyn;
  628.   goto yynewstate;
  629.  
  630. /* Do the default action for the current state.  */
  631. yydefault:
  632.  
  633.   yyn = yydefact[yystate];
  634.   if (yyn == 0)
  635.     goto yyerrlab;
  636.  
  637. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  638. yyreduce:
  639.   yylen = yyr2[yyn];
  640.   if (yylen > 0)
  641.     yyval = yyvsp[1-yylen]; /* implement default value of the action */
  642.  
  643. #if YYDEBUG != 0
  644.   if (yydebug)
  645.     {
  646.       int i;
  647.  
  648.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  649.            yyn, yyrline[yyn]);
  650.  
  651.       /* Print the symbols being reduced, and their result.  */
  652.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  653.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  654.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  655.     }
  656. #endif
  657.  
  658.  
  659.   switch (yyn) {
  660.  
  661. case 1:
  662. #line 62 "bi-parser.y"
  663. { defs = yyvsp[0].def; ;
  664.     break;}
  665. case 3:
  666. #line 68 "bi-parser.y"
  667. { yyvsp[0].def->next = yyvsp[-1].def; yyval.def = yyvsp[0].def; ;
  668.     break;}
  669. case 4:
  670. #line 73 "bi-parser.y"
  671. { yyval.def = makedef (yyvsp[-7].string, yyvsp[-5].string, yyvsp[-2].variation); ;
  672.     break;}
  673. case 6:
  674. #line 79 "bi-parser.y"
  675. { yyvsp[0].variation->next = yyvsp[-2].variation; yyval.variation = yyvsp[0].variation; ;
  676.     break;}
  677. case 7:
  678. #line 84 "bi-parser.y"
  679. { yyval.variation = makevar (yyvsp[-1].string, (struct node *) NULL, (struct node *) NULL, (struct node *) NULL); ;
  680.     break;}
  681. case 8:
  682. #line 86 "bi-parser.y"
  683. { yyval.variation = makevar (yyvsp[-3].string, yyvsp[-1].node, (struct node *) NULL, (struct node *) NULL); ;
  684.     break;}
  685. case 9:
  686. #line 88 "bi-parser.y"
  687. { yyval.variation = makevar (yyvsp[-5].string, yyvsp[-3].node, yyvsp[-1].node, (struct node *) NULL); ;
  688.     break;}
  689. case 10:
  690. #line 90 "bi-parser.y"
  691. { yyval.variation = makevar (yyvsp[-7].string, yyvsp[-5].node, yyvsp[-3].node, yyvsp[-1].node); ;
  692.     break;}
  693. case 11:
  694. #line 94 "bi-parser.y"
  695. { yyval.string = ""; ;
  696.     break;}
  697. case 12:
  698. #line 95 "bi-parser.y"
  699. { yyval.string = yyvsp[0].string; ;
  700.     break;}
  701. case 13:
  702. #line 100 "bi-parser.y"
  703. { yyval.node = yyvsp[-1].node; ;
  704.     break;}
  705. case 14:
  706. #line 102 "bi-parser.y"
  707. { yyval.node = NULL; ;
  708.     break;}
  709. case 16:
  710. #line 109 "bi-parser.y"
  711. { yyvsp[-2].node->next = yyvsp[0].node; yyval.node = yyvsp[-2].node; ;
  712.     break;}
  713. case 17:
  714. #line 114 "bi-parser.y"
  715. { yyval.node = makenode (yyvsp[0].string); ;
  716.     break;}
  717. }
  718.    /* the action file gets copied in in place of this dollarsign */
  719. #line 480 "/usr/local/lib/bison.simple"
  720.  
  721.   yyvsp -= yylen;
  722.   yyssp -= yylen;
  723. #ifdef YYLSP_NEEDED
  724.   yylsp -= yylen;
  725. #endif
  726.  
  727. #if YYDEBUG != 0
  728.   if (yydebug)
  729.     {
  730.       short *ssp1 = yyss - 1;
  731.       fprintf (stderr, "state stack now");
  732.       while (ssp1 != yyssp)
  733.     fprintf (stderr, " %d", *++ssp1);
  734.       fprintf (stderr, "\n");
  735.     }
  736. #endif
  737.  
  738.   *++yyvsp = yyval;
  739.  
  740. #ifdef YYLSP_NEEDED
  741.   yylsp++;
  742.   if (yylen == 0)
  743.     {
  744.       yylsp->first_line = yylloc.first_line;
  745.       yylsp->first_column = yylloc.first_column;
  746.       yylsp->last_line = (yylsp-1)->last_line;
  747.       yylsp->last_column = (yylsp-1)->last_column;
  748.       yylsp->text = 0;
  749.     }
  750.   else
  751.     {
  752.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  753.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  754.     }
  755. #endif
  756.  
  757.   /* Now "shift" the result of the reduction.
  758.      Determine what state that goes to,
  759.      based on the state we popped back to
  760.      and the rule number reduced by.  */
  761.  
  762.   yyn = yyr1[yyn];
  763.  
  764.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  765.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  766.     yystate = yytable[yystate];
  767.   else
  768.     yystate = yydefgoto[yyn - YYNTBASE];
  769.  
  770.   goto yynewstate;
  771.  
  772. yyerrlab:   /* here on detecting error */
  773.  
  774.   if (! yyerrstatus)
  775.     /* If not already recovering from an error, report this error.  */
  776.     {
  777.       ++yynerrs;
  778.  
  779. #ifdef YYERROR_VERBOSE
  780.       yyn = yypact[yystate];
  781.  
  782.       if (yyn > YYFLAG && yyn < YYLAST)
  783.     {
  784.       int size = 0;
  785.       char *msg;
  786.       int x, count;
  787.  
  788.       count = 0;
  789.       /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
  790.       for (x = (yyn < 0 ? -yyn : 0);
  791.            x < (sizeof(yytname) / sizeof(char *)); x++)
  792.         if (yycheck[x + yyn] == x)
  793.           size += strlen(yytname[x]) + 15, count++;
  794.       msg = (char *) malloc(size + 15);
  795.       if (msg != 0)
  796.         {
  797.           strcpy(msg, "parse error");
  798.  
  799.           if (count < 5)
  800.         {
  801.           count = 0;
  802.           for (x = (yyn < 0 ? -yyn : 0);
  803.                x < (sizeof(yytname) / sizeof(char *)); x++)
  804.             if (yycheck[x + yyn] == x)
  805.               {
  806.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  807.             strcat(msg, yytname[x]);
  808.             strcat(msg, "'");
  809.             count++;
  810.               }
  811.         }
  812.           yyerror(msg);
  813.           free(msg);
  814.         }
  815.       else
  816.         yyerror ("parse error; also virtual memory exceeded");
  817.     }
  818.       else
  819. #endif /* YYERROR_VERBOSE */
  820.     yyerror("parse error");
  821.     }
  822.  
  823.   goto yyerrlab1;
  824. yyerrlab1:   /* here on error raised explicitly by an action */
  825.  
  826.   if (yyerrstatus == 3)
  827.     {
  828.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  829.  
  830.       /* return failure if at end of input */
  831.       if (yychar == YYEOF)
  832.     YYABORT;
  833.  
  834. #if YYDEBUG != 0
  835.       if (yydebug)
  836.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  837. #endif
  838.  
  839.       yychar = YYEMPTY;
  840.     }
  841.  
  842.   /* Else will try to reuse lookahead token
  843.      after shifting the error token.  */
  844.  
  845.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  846.  
  847.   goto yyerrhandle;
  848.  
  849. yyerrdefault:  /* current state does not do anything special for the error token. */
  850.  
  851. #if 0
  852.   /* This is wrong; only states that explicitly want error tokens
  853.      should shift them.  */
  854.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  855.   if (yyn) goto yydefault;
  856. #endif
  857.  
  858. yyerrpop:   /* pop the current state because it cannot handle the error token */
  859.  
  860.   if (yyssp == yyss) YYABORT;
  861.   yyvsp--;
  862.   yystate = *--yyssp;
  863. #ifdef YYLSP_NEEDED
  864.   yylsp--;
  865. #endif
  866.  
  867. #if YYDEBUG != 0
  868.   if (yydebug)
  869.     {
  870.       short *ssp1 = yyss - 1;
  871.       fprintf (stderr, "Error: state stack now");
  872.       while (ssp1 != yyssp)
  873.     fprintf (stderr, " %d", *++ssp1);
  874.       fprintf (stderr, "\n");
  875.     }
  876. #endif
  877.  
  878. yyerrhandle:
  879.  
  880.   yyn = yypact[yystate];
  881.   if (yyn == YYFLAG)
  882.     goto yyerrdefault;
  883.  
  884.   yyn += YYTERROR;
  885.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  886.     goto yyerrdefault;
  887.  
  888.   yyn = yytable[yyn];
  889.   if (yyn < 0)
  890.     {
  891.       if (yyn == YYFLAG)
  892.     goto yyerrpop;
  893.       yyn = -yyn;
  894.       goto yyreduce;
  895.     }
  896.   else if (yyn == 0)
  897.     goto yyerrpop;
  898.  
  899.   if (yyn == YYFINAL)
  900.     YYACCEPT;
  901.  
  902. #if YYDEBUG != 0
  903.   if (yydebug)
  904.     fprintf(stderr, "Shifting error token, ");
  905. #endif
  906.  
  907.   *++yyvsp = yylval;
  908. #ifdef YYLSP_NEEDED
  909.   *++yylsp = yylloc;
  910. #endif
  911.  
  912.   yystate = yyn;
  913.   goto yynewstate;
  914. }
  915. #line 117 "bi-parser.y"
  916.  
  917.  
  918. static struct node *
  919. makenode (s)
  920.      char *s;
  921. {
  922.   struct node *n;
  923.  
  924.   n = (struct node *) malloc (sizeof (struct node));
  925.   n->text = s;
  926.   n->next = NULL;
  927.   return n;
  928. }
  929.  
  930. static struct variation *
  931. makevar (name, inputs, outputs, literals)
  932.      char *name;
  933.      struct node *inputs, *outputs, *literals;
  934. {
  935.   struct variation *v;
  936.  
  937.   v = (struct variation *) malloc (sizeof (struct variation));
  938.   v->name = name;
  939.   v->code = ndefs++;
  940.   v->inputs = inputs;
  941.   v->outputs = outputs;
  942.   v->literals = literals;
  943.   v->next = NULL;
  944.   return v;
  945. }
  946.  
  947. static struct def *
  948. makedef (name, template, vars)
  949.      char *name, *template;
  950.      struct variation *vars;
  951. {
  952.   struct def *d;
  953.  
  954.   d = (struct def *) malloc (sizeof (struct def));
  955.   d->basename = name;
  956.   d->template = template;
  957.   d->variations = vars;
  958.   d->next = NULL;
  959.   return d;
  960. }
  961.  
  962. void
  963. yyerror (s)
  964.      char *s;
  965. {
  966.   fprintf (stderr, "syntax error in input\n");
  967.   exit (FATAL_EXIT_CODE);
  968. }
  969.